package com.alex.springboot.controller;

import com.alex.springboot.dao.RedisRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/redis")
public class RedisController {

    @Autowired
    private RedisRepository redisRepository;

    @PostMapping("/set")
    public void set(String key, String value) {
        redisRepository.set(key, value);
    }

    @PostMapping("/setExpire")
    public void setExpire(String key, String value, Integer expire) {
        redisRepository.set(key, value, expire);
    }

    @GetMapping("/get")
    public String get(String key) {
        return redisRepository.get(key);
    }

}
